<?xml version="1.0" encoding="UTF-8"?>
<ui:composition
	xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
	xmlns:f="http://xmlns.jcp.org/jsf/core"
	xmlns:h="http://xmlns.jcp.org/jsf/html"
	xmlns:p="http://primefaces.org/ui"
	xmlns:c="http://xmlns.jcp.org/jsp/jstl/core"
	template="/WEB-INF/templates/business/supplier/template.xhtml">

	<f:metadata>
	
		<f:viewParam name="dictId" value="#{dictHome.id}"></f:viewParam>
		<f:viewParam name="supplierId" value="#{serviceSupplierHome.id}"></f:viewParam>
		<f:viewParam name="existAssessRecordId" value="#{existAssessRecordHome.id}"></f:viewParam>
		
		<f:viewParam name="assessRecordId" value="#{assessRecordHome.id}" />
		<f:viewParam name="taskId" value="#{bpmHome.taskId}"></f:viewParam>
		
		<f:event listener="#{assessRecordHome.initConversation()}" type="preRenderView"></f:event>
		
	</f:metadata>
	<ui:define name="supplier_head">

		<style type="text/css">
			.column1 {
				width: 20%;
			}
			
			.column2 {
				width: 80%;
			}
			
			.top-alignment {
				vertical-align: top;
			}
			
			.removeButton {
				float: right;
				margin-right: 20px;
			}
			
			td {
				padding-bottom: 10px;
			}
			
			label {
				font-weight: bold;
			}
			
			.photoItem {
				float: left;
			}
		</style>
	</ui:define>
	<ui:define name="supplier_content">

		<h:form id="editForm">

			<p:messages
				id="messages"
				closable="true">
				<p:autoUpdate />
			</p:messages>

			<p:panel
				header="上报【#{dictHome.instance.title}】证明材料"
				style="margin-bottom:10px">
				
				<p:fileUpload
					mode="advanced"
					multiple="true"
					sequential="true"
					label="请选择图片"
					required="true"
					skinSimple="true"
					allowTypes="/(\.|\/)(jpe?g|png)$/"
					invalidFileMessage="文件类型错误，请上传png或jpg格式的图片"
					sizeLimit="#{1024 * 1024 * 3}"
					invalidSizeMessage="文件大小不能超过3M!"
					uploadLabel="上传"
					cancelLabel="取消"
					update="editForm:uploadedImages"
					fileUploadListener="#{assessRecordHome.uploadImage}"></p:fileUpload>					
				
				<p:dataTable id="uploadedImages" value="#{assessRecordHome.instance.images}" var="_attr" rowIndexVar="_row">
				
					<p:column headerText="文件名">
						<h:outputText value="#{_attr.filename}" />
					</p:column>
										
					<p:column headerText="大小（MB）" style="text-align: right;">
						<h:outputText value="#{_attr.filesize / 1024 / 1024}">	
							<f:convertNumber minFractionDigits="2" groupingUsed="true" />
						</h:outputText>
					</p:column>
					
					<p:column headerText="预览">
						<img data-original="#{attachmentUtils.getFullPath( _attr )}" src="#{attachmentUtils.getFullPath( _attr )}" width="240"/>
					</p:column>
					
					<p:column headerText="操作">						
						<p:commandLink styleClass="closeBtn" action="#{assessRecordHome.removeImage(_row)}"  update="editForm:uploadedImages" immediate="true" ></p:commandLink>
					</p:column>
					
				</p:dataTable>
				
				<hr style="margin-top: 20px; margin-bottom: 20px;" />
				
				<p:fileUpload
					mode="advanced"
					multiple="true"
					sequential="true"
					label="请选择文件"
					required="true"
					skinSimple="true"
					invalidSizeMessage="文件大小不能超过3M!"
					sizeLimit="#{1024 * 1024 * 3}"			
					uploadLabel="上传"
					cancelLabel="取消"
					update="editForm:uploadedAttachments"
					fileUploadListener="#{assessRecordHome.uploadAttachments}"></p:fileUpload>					
				
				<p:dataTable id="uploadedAttachments" value="#{assessRecordHome.instance.attachments}" var="_attr" rowIndexVar="_row">
				
					<p:column headerText="文件名">
						<h:outputText value="#{_attr.filename}" />
					</p:column>
										
					<p:column headerText="大小（MB）" style="text-align: right;">
						<h:outputText value="#{_attr.filesize / 1024 / 1024}">	
							<f:convertNumber minFractionDigits="2" groupingUsed="true" />
						</h:outputText>
					</p:column>
					
					<p:column headerText="操作">						
						<p:commandLink styleClass="closeBtn" action="#{assessRecordHome.removeAttachment(_row)}"  update="editForm:uploadedAttachments" immediate="true" ></p:commandLink>
					</p:column>
					
				</p:dataTable>
				
			</p:panel>

			<p:commandButton
				id="submitBtn"
				action="#{assessRecordHome.supplierSaveAndFlush()}"
				value="保存"
				ajax="true">
				<p:tooltip
					id="toolTipGrow1"
					for="submitBtn"
					value="重新提交需要重新审核，在此期间您因此项获得的信用分将暂时归零，您确认要提交吗？"
					showEffect="clip"
					hideEffect="explode"
					position="bottom"
					rendered="#{existAssessRecordHome.instance.recordStatus.name() == 'Keeped'}" />
			</p:commandButton>

		</h:form>

		<p:dialog
			id="infoTip"
			visible="true"
			closable="false"
			showEffect="true"
			widgetVar="infoTip"
			width="666"
			height="300"
			modal="true"
			rendered="#{existAssessRecordHome.instance.recordStatus.name() == 'Keeped'}" >
			<h:form>
				<p:panel>
					<f:facet name="header">请注意</f:facet>
					<p:panel>
						<font style="font-size: 16px; color: red; padding: 10px">
							重新提交需要重新审核，在此期间您因此项获得的信用分将暂时归零，您确认要修改吗？ </font>

					</p:panel>

					<f:facet name="footer">
						<p:commandButton
							value="确定提交"
							onclick="PF('infoTip').hide();" />
						<p:button
							value="取消"
							outcome="AssessRecordForSupplierList.xhtml">
							<f:param name="periodType" value="#{dictHome.instance.periodType}"></f:param>
						</p:button>
					</f:facet>
				</p:panel>
			</h:form>
		</p:dialog>

	</ui:define>

</ui:composition>
